export default {
    data() {
        return {
            dialogVisible: false,
            removeId: 0,
            tableData: [],
            total: 100,
            page: 1,
            size: 10,
        }
    },
    methods: {
        check(row) {
            localStorage.setItem("_id", row._id);
            this.$router.push({
                name: "detail",
                params: {
                    _id: row._id
                }
            })
        },
        async remove() {
            const res = await this.$http.post("data/delete",{
                _id: this.removeId
            })
            console.log(res.data);
            this.fetchData();
            this.dialogVisible = false;
            this.$message({
                type: "success",
                message: "删除成功!"
            })
        },
        currentChange(page) {
            this.page = page;
            this.fetchData();
        },
        sizeChange(size) {
            this.size = size;
            this.fetchData();
        },
        async fetchData() {
            const res = await this.$http.get("data",{
                params: {
                    page: this.page,
                    size: this.size
                }
            });
            this.tableData = res.data.data;
            this.total = res.data.total;
        }
    },
    created() {
        this.fetchData();
    }
}